<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>客户编辑</title>
<link href="/resources/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="/resources/lib/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
<script src="/resources/lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="/resources/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
<!-- <script src="/resources/lib/ligerUI/js/plugins/ligerForm.js" type="text/javascript"></script> -->
<script src="/resources/lib/jquery-validation/jquery.validate.min.js" type="text/javascript"></script> 
<script src="/resources/lib/jquery-validation/jquery.metadata.js" type="text/javascript"></script>
<script src="/resources/lib/jquery-validation/messages_cn.js" type="text/javascript"></script>
<script src="/resources/lib/json2.js" type="text/javascript"></script>
<script src="/resources/js/jsF7.js" type="text/javascript"></script>
<script src="/resources/js/selectData.js" type="text/javascript"></script>
<script src="/resources/js/themis.js" type="text/javascript"></script>
<script src="/resources/js/validation.js" type="text/javascript"></script><style type="text/css">
    .l-table-edit {}
    .l-table-edit-td-label{width: 100px;padding-top: 5px;}
    .l-table-edit-td-input{width: 200px;padding-top: 5px;}
    .div-buttom{position: absolute;top:380px;}
    
</style>
<script type="text/javascript">
var form1 = null;
var toolbar = null;
var info = '${info}';
var existData = null;
if(info){
	existData = JSON.parse(info); 
}
var status = '${status}';
var number = '${number}';

 
$(function (){
    //工具条
    toolbar = $("#toptoolbar").ligerToolBar({ items: [
        { text: '保存', id:'save',click: saveForm,icon: 'save' }
    ]
    });
  //创建表单(头部)
    form1 = $("#form1").ligerForm({
    inputWidth: 170, labelWidth: 90, space: 40,
    validate:true,
    fields: [
        { name: "uuid", type: "hidden" },
        { display: "编号", name: "number", type: "text",newline: false, validate: { required: true} },
        { display: "名称", name: "name", type: "text",newline: false,  validate: { required: true} }
        ]
    });
  if(existData){
	  form1.setData(existData);
  }
  if(number){
	  form1.setData({number:number});
  }
  if(status && status =='1'){
	  toolbar.setDisabled('save');
	  form1.setAllEnabled(false);
  }
});

//保存
function saveForm(){
   // var forms = $('#form1').serialize(); 
    var data = form1.getData();
   // data = JSON.stringify(data);
    console.log(data);
    if(form1.valid()){
	 	$.ajax({
	        loading: '正在保存数据中...',
	        type:'post',
	        url: "/customerClassification/saveOrUpdateCustomerClassification",
			dataType:'json',
	        data: {customerClassification:JSON.stringify(data)},
	        success: function (data) {
					$.ligerDialog.success(data.message,'信息',function(){
						$("#uuid").val(data.data.uuid);
				    });
	        },
	        error: function (message) {
	       	 	$.ligerDialog.error("保存失败");
	        }
	    });
    }
}
</script>
</head>
<body>
	<div id="toptoolbar"></div>
	<form id="form1"></form>
</body>
</html>